import json

def check_json(xpath, xtypes):
    print(f'Reading {xpath}')
    with open(xpath, 'r', encoding='utf8') as fi:
        xcont = fi.read()
        xlen = len(xcont)
        print(f'Length: {xlen:,d}')
        xdata = json.loads(xcont)
    for xobj in xdata:
        for xen_obj in xobj['entities']:
            xtypes.add(xen_obj['type'])


if '__main__' == __name__:

    def _main():
        xpath_arr = [
            r'D:\_dell7590_root\local\LNP_datasets\med\CBLUE\CMeEE-V2\CMeEE-V2_dev.json',
            r'D:\_dell7590_root\local\LNP_datasets\med\CBLUE\CMeEE-V2\CMeEE-V2_train.json',
        ]
        xtypes = set()
        for xpath in xpath_arr:
            check_json(xpath, xtypes)
        xlen = len(xtypes)
        print(xlen)
        print(sorted(xtypes))  # ['bod', 'dep', 'dis', 'dru', 'equ', 'ite', 'mic', 'pro', 'sym']

    _main()
